package com.org.gsc.zsqdemos.uis;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.org.gsc.zsqdemos.R;
import com.org.gsc.zsqdemos.adapters.MypstAdapter;
import com.viewpagerindicator.TabPageIndicator;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by qundui on 2017/6/18.
 */

public class PageIndicatiorDemo extends FragmentActivity {
    private TabPageIndicator titlePageIndicator;
    private ViewPager viewPager;
    List<String> titles;
    private MypstAdapter mypstAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.pagedemo);
        titlePageIndicator= (TabPageIndicator) findViewById(R.id.titles);
        viewPager= (ViewPager) findViewById(R.id.vp);
         titles=new ArrayList<>();
        for(int i=0;i<15;i++){
            titles.add("第"+(i+1)+"个标签");
        }

        mypstAdapter = new MypstAdapter(getSupportFragmentManager(), titles);
        viewPager.setAdapter(mypstAdapter);
        titlePageIndicator.setViewPager(viewPager);
    }
    public void mimus(View v){
        titles.remove(3);
        titlePageIndicator.notifyDataSetChanged();
        mypstAdapter.notifyDataSetChanged();

    }
    public void add(View v){
        titles.add("ADBC");
        titlePageIndicator.notifyDataSetChanged();
        mypstAdapter.notifyDataSetChanged();
    }
}
